package com.fs.system.student.controller;

import com.fs.system.common.ResponseData;
import com.fs.system.student.domain.ApplicationRecord;
import com.fs.system.student.service.ApplicationRecordService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/applicationRecord")
public class ApplicationRecordController {

    @Resource
    private ApplicationRecordService applicationRecordService;

    @PostMapping("/submitApply")
    public ResponseData submitApply(@RequestBody ApplicationRecord applicationRecord){
        applicationRecordService.submitApply(applicationRecord);
        return new ResponseData("200","申请成功");
    }

    @GetMapping("/selectApplyRecordList")
    public ResponseData selectApplyRecordList(ApplicationRecord applyRecord) {
        List<ApplicationRecord> applyRecordList = applicationRecordService.selectApplyRecordList(applyRecord);
        return new ResponseData("200", "查询成功",applyRecordList);
    }

    @GetMapping("/selectPage")
    public ResponseData selectPage(
            ApplicationRecord applyRecord,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "5") Integer pageSize
    ) {
        PageInfo<ApplicationRecord> applyRecordPageInfo = applicationRecordService.selectPage(applyRecord,pageNum, pageSize);
        return new ResponseData("200", "查询成功",applyRecordPageInfo);
    }
}
